﻿
using System.Linq;
namespace SanguoSharp.Server.Cards
{
    public sealed class 闪电 : TableCard
    {
        public 闪电(Game game, int id, CardSuit suit, CardRank rank)
            : base(game, id, CardType.闪电, suit, rank)
        {
        }

        protected override void OnPredrawCheck()
        {
            Owner.CheckDeck(this, c => c.Suit != CardSuit.黑桃 || c.Rank < CardRank.Two && c.Rank > CardRank.Nine, OnResult);
        }

        private void OnResult(Card causedBy, bool result)
        {
            if (result)
            {
                Player next = Game.NextPlayer(Owner);
                if (!next.Table.Any(c => c.Type == CardType.闪电))
                    Game.GameTable.PassTableCard(this, next);
            }
            else
            {
                Player owner = Owner;
                Game.GameTable.CancelCard(this);
                owner.ModifyLifePoints(-3);
            }
        }
    }
}

